package com.htbb.controller.carInsure;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.htbb.common.base.Result;
import com.htbb.common.base.exception.BizException;
import com.htbb.common.msgBodyAdvice.CryptionType;
import com.htbb.model.carInsure.ReqOfCarIsu;
import com.htbb.service.carInsure.TcCarInsureService;

/**
 * @date 2017-5-23 
 * @description 业务流程接口
 * @author wuyongde
 *
 */
@Controller
@RequestMapping(value = "carInsure")
public class CarIsuBizController {
	@Autowired
	private TcCarInsureService tcCarInsureService;
	
	/**
	 * 车险投保接口
	 * @param checkInfo
	 * @return
	 * @throws Exception
	 */
	@CryptionType
	@ResponseBody
	@RequestMapping(value = "submitOrder", method = { RequestMethod.POST}, produces = "application/json;charset=UTF-8")
	public Object submitOrder(@RequestBody ReqOfCarIsu reqOfCarIsu)
			throws Exception {
		
		return new Result<Object>(tcCarInsureService.carIsuSubmit(reqOfCarIsu));

	}

	/**
	 * 车险订单查询
	 * @param reqParams
	 * @return
	 * @throws Exception
	 */
	@CryptionType
	@ResponseBody
	@RequestMapping(value = "query", method = { RequestMethod.GET,RequestMethod.POST }, produces = "application/json;charset=UTF-8")
	public Object queryOrder(@RequestBody Map<String, String> reqParams) throws Exception {

		String orderId = reqParams.get("orderId");
		if(StringUtils.isEmpty(orderId)){
			throw new BizException("参数orderId缺失！");
		}
		return new Result<Object>(tcCarInsureService.getOrderDetail(orderId));
	}
}






